#!/usr/bin/env python
# coding=utf-8

from pathlib import Path
from conf_parser import load_yml_config_list


class ConfMgr:
    def __init__(self, options=None, parsed=False):
        self.options = options
        self.parsed = parsed


confm = ConfMgr()


def get_option(key, default=None):
    if not confm.parsed:
        confm.options = load_yml_config_list(
            Path("~/.qplatform/data_conf.yml"),
            Path("~/.config/qplatform/data_conf.yml"),
            Path("/etc/qplatform/data_conf.yml"),
            Path(__file__).parent / "data_conf.yml",
        )
        confm.parsed = True
    return confm.options.get(key, default)
